Skip to content

Fix thread-safety in GlobalKaleidoServer: replace shared return queue with per-task Futures#431

Open
talleibman wants to merge 1 commit intoplotly:masterfrom
talleibman:fix/per-task-futures-thread-safety
Open

Fix thread-safety in GlobalKaleidoServer: replace shared return queue with per-task Futures#431
talleibman wants to merge 1 commit intoplotly:masterfrom
talleibman:fix/per-task-futures-thread-safety

Conversation

@talleibman
Copy link
Copy Markdown

@talleibman talleibman commented Feb 27, 2026

Closes #444.

We hit an issue in production where concurrent call_function calls occasionally returned each other's results. The shared _return_queue has no guarantee that the caller who put the task gets the matching result back.

Fix: each Task now carries its own concurrent.futures.Future. The worker sets the result/exception directly on it, and the caller blocks on future.result().

Tested locally with Python 3.8 and 3.14.

Thanks for the review!

Avoids potential result/caller mismatch when multiple threads call
call_function concurrently—each caller now blocks on its own Future.
@emilykl
Copy link
Copy Markdown
Collaborator

emilykl commented Apr 21, 2026

Thank you @talleibman for the PR. I've opened issue #444 to track the reported bug. We're currently investigating #441 which may be related, so we may not be able to review this PR immediately until we better understand the scope of the issue but we're aware of the problem and working on determining the best fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GlobalKaleidoServer is not thread-safe

4 participants